사이트 내 전체검색
HTML과 플래시의 통신 - 로그인 여부에 따라 달라지는 플래시
로빈아빠
https://cmd.kr/html/52 URL이 복사되었습니다.

본문

플래시 작업화면입니다.
서브메뉴의 구현방법은 앞의 것과 비슷합니다.
메뉴에 마우스가 올라갈 경우, 왔다갔다하는 선택자가 빠진 대신
큰메뉴 한글이 위로 올라가면서 색이 바뀌고
영문 글씨가 점차 투명해지는 효과만 주었습니다.

이런 효과는 이미 앞에서 다 나온것이므로 생략하기로 하고
이번 예제에서는 HTML과 플래시와의 통신에 대해 이야기하겠습니다.

HTML이 플래시(쇽웨이브파일)에게 무엇인가를 전달하고자 한다면,
XML이나 CGI를 이용한 방법도 있겠으나 간단히 GET방식으로 전달하면 됩니다.
GET 이란 전달방법은 URL뒤에 ?표를 붙인 후 전달할 변수명과 변수값을 나열하는
방법을 말합니다.

(ex.) http://www.ziwoo.net/zb/list.php?boardid=zb_ziwoo_actionscript&startPage=1

위의 예제에서 list.php를 호출하되,
boardid라는 변수명에는 zb_ziwoo_actionscript 라는 값을
startPage 라는 변수명에는 1 을 대입하라는 의미입니다.
예제처럼 주소와 변수의 구분은 ?표로 하고 변수끼리는 &표로 구분합니다.

PHP나 혹은 ASP등의 웹언어에서는 로그인된 경우와 안된 경우를 쉽게 구분할 수 있습니다.
if($_SESSION["login_id"]) $logStatus="yes";
else $logStatus="no";
처럼 로그인한 경우와 안한 경우를 구분하여
변수 logStatus에 "yes" 혹은 "no"을 대입할 수 있는것입니다.

플래시를 호출하는 HTML소스의 예를 보겠습니다.

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="~~">
<param name="movie" value="/images/symbol.swf">
<param name="quality" value="high">
<param name="bgcolor" value="#ffffff">
<embed src="/images/symbol.swf" quality="high" bgcolor="#ffffff" width="112" height="31" name="symbol" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash">
<object>

이 예제에서 2번째 줄과 5번째 줄에 "/images/symbol.swf"라는 파일경로가 있는것이 보입니다.
이제 이 경로를 로그인 여부에 따라 GET 방식으로 전환해보겠습니다.

변경전 : images/symbol.swf
변경후 : images/symbol.swf?mststus=<?=$logStatus?>

<?=$logStatus?> 부분은 PHP가 알아서 해주는 부분이며, 로그인 여부에 따라
"yes"와 "no"을 표시하게됩니다. 위 코드의 소스보기를 해보면
images/symbol.swf?mststus=yes 혹은
images/symbol.swf?mststus=no 처럼 되겠지요.

이것으로 HTML 이 플래시에게 전달하는것은 끝났습니다.
이젠 플래시가 이것을 어떻게 받아쓰는가만 정리하면 됩니다.

아래 첨부된 액션전체내용에서 처음 6줄이 그것입니다.

if(_root.mststus=="yes") {
    _root["r2"]._x = 730;
    _root["r3"]._x = 730;
    _root["r2m"]._x = 630;
    _root["r3m"]._x = 630;
}

위의 액션스크립트 내용에서 보듯이 HTML이 던져준 mststus 라는 변수를
액션스크립트에서는 _root.mststus로 받으면 됩니다.
만약 mststus의 값이 "yes" 라면
[로그인]버튼과 [회원가입]버튼을 오른쪽 화면밖으로 빼고
[로그아웃]버튼과 [회원정보]버튼을 화면안으로 이동시키라는 뜻입니다.
r2, r3, r2m, r3m은  로그인, 회원가입, 로그아웃, 회원정보 버튼의 인스턴스이름입니다.

이렇게하면 간단히 처리될 내용을 많은 디자이너들이 두개의 플래시를 만든다고 고생들을 합니다.
이제부터는 고생하지 마시고 GET 전달방법을 이용해보세요.


== 액션전체내용 ==
if(_root.mststus=="yes") { //로그인 한 경우 버튼위치 교환
    _root["r2"]._x = 730;
    _root["r3"]._x = 730;
    _root["r2m"]._x = 630;
    _root["r3m"]._x = 630;
}

for (j=1; j<=5; j++) {
    this[j]._alpha = 0;
    _root["sub"+j]._y = 77; //대기선   
    this["sub"+j][1]._alpha = 0; //메뉴당 서브의 갯수만큼 투명하게..
    this["sub"+j][2]._alpha = 0;
    this["sub"+j][3]._alpha = 0;   
    this["sub"+j][4]._alpha = 0;   
    this["sub"+j][5]._alpha = 0;   

    this[j].onRollOver = function() {
        this.over = 1;
        this.subover = 1;
    };
   
    this[j].onRollOut = function() {
        this.over = 0;
    };
   
    this[j].onEnterFrame = function() {
        Obj = _root["sub"+this._name];
        if(this.over==1 && _root["sub"+this._name].hitTest(_root._xmouse,_root._ymouse,false)) {this.subover = 1;}
        if(this.over==0 && !_root["sub"+this._name].hitTest(_root._xmouse,_root._ymouse,false)) {this.subover = 0;}   

        if (this.over==1 || this.subover==1) {
            myColor = new Color("_root."+this._name+"kor");
            myColor.setRGB(0x60B4DD);
            if(_root["sub"+this._name]._y>49) _root["sub"+this._name]._y -= 7;
            if(_root["sub"+this._name]._alpha<100) _root["sub"+this._name]._alpha += 20;
            if(_root[this._name+"kor"]._y>9) _root[this._name+"kor"]._y -= 2;
            if(_root[this._name+"eng"]._alpha>0)  _root[this._name+"eng"]._alpha -= 20;
            if(_root[this._name+"eng"]._y>-3) _root[this._name+"eng"]._y -= 2;
        }else{
            myColor = new Color("_root."+this._name+"kor");
            myColor.setRGB(0x5F5F5F);   
            if(_root["sub"+this._name]._y<77) _root["sub"+this._name]._y += 7;
            if(_root["sub"+this._name]._alpha>0) _root["sub"+this._name]._alpha -= 15;
            if(_root[this._name+"kor"]._y<17) _root[this._name+"kor"]._y += 2;
            if(_root[this._name+"eng"]._alpha<100)  _root[this._name+"eng"]._alpha += 20;
            if(_root[this._name+"eng"]._y<3) _root[this._name+"eng"]._y += 2;
        }
    };
}

for (j=1; j<=4; j++) {
    _root["r"+j].onRollOver = function() {
            this.gotoAndStop(2);
    };
    _root["r"+j].onRollOut = function() {
            this.gotoAndStop(1);
    };
    _root["r"+j+"m"].onRollOver = function() {
            this.gotoAndStop(2);
    };
    _root["r"+j+"m"].onRollOut = function() {
            this.gotoAndStop(1);
    };   
}

this[1].onRelease = function() {getURL("#","_self");}
this[2].onRelease = function() {getURL("#","_self");}
this[3].onRelease = function() {getURL("#","_self");}
this[4].onRelease = function() {getURL("#","_self");}
this[5].onRelease = function() {getURL("#","_self");}

this["sub1"][1].onRelease = function() {getURL("3","_self");}
this["sub1"][2].onRelease = function() {getURL("#","_self");}
this["sub1"][3].onRelease = function() {getURL("#","_self");}

this["sub2"][1].onRelease = function() {getURL("#","_self");}
this["sub2"][2].onRelease = function() {getURL("#","_self");}
this["sub2"][3].onRelease = function() {getURL("#","_self");}

this["sub3"][1].onRelease = function() {getURL("#","_self");}
this["sub3"][2].onRelease = function() {getURL("#","_self");}
this["sub3"][3].onRelease = function() {getURL("#","_self");}

this["sub4"][1].onRelease = function() {getURL("#","_self");}
this["sub4"][2].onRelease = function() {getURL("#","_self");}

this["sub5"][1].onRelease = function() {getURL("/zb/list.php?boardid=zb_notice","_self");}
this["sub5"][2].onRelease = function() {getURL("/zb/open.php?boardid=zb_guestbook","_self");}
this["sub5"][3].onRelease = function() {getURL("/zb/list.php?boardid=zb_free","_self");}
this["sub5"][4].onRelease = function() {getURL("/zb/list.php?boardid=zb_photo","_self");}
this["sub5"][5].onRelease = function() {getURL("/enq/enq.html","_self");}


this["r1"].onRelease = function() {getURL("/","_self");}
this["r2"].onRelease = function() {getURL("/zm/login.html","_self");}
this["r3"].onRelease = function() {getURL("/zm/join.html","_self");}
this["r4"].onRelease = function() {getURL("/sub/contact.html","_self");}

this["r2m"].onRelease = function() {getURL("/zm/logout.html","_self");}
this["r3m"].onRelease = function() {getURL("/zm/modify.html","_self");}

첨부파일

댓글목록

등록된 댓글이 없습니다.

Search

Copyright © Cmd 명령어 3.128.199.175